class friendly {
  constructor(board) {
    this.ctx = board.ctx
    this.board = board
    this.img = images['friendly']
    this.randomY = Math.random() * 525
    this.x = 950
    this.width = 80
    this.height = 80
    this.id = board.friendlyId
    this.friendlyBj = 0
    this.timerIndex = 0
    this.speed = 5
  }
  draw() {
    this.timerIndex++
    if (this.timerIndex > 5) {
      this.timerIndex = 0
      this.friendlyBj++
    }
    this.x -= this.speed
    this.ctx.drawImage(this.img, 80 * (this.friendlyBj % 4), 0, 80, 80, this.x, this.randomY, this.width, this.height)
    if (this.x < -100) {
      delete this.board.friendlyObj[this.id]
    }
  }
}

export { friendly }